<?php
	require_once("../conexion/conexion.php");
	
	function BuscaNCDia($num)
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select NotCreNum from notfacdia where FacDiaCod='".$num."'";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$fila = mysql_fetch_array($res);
		$con->cerrarBD();
		return $fila[0];
	}
	
	function BuscaNCInfa($num)
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select NotCreNum from notfacinfa where FacInfaCod='".$num."'";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$fila = mysql_fetch_array($res);
		$con->cerrarBD();
		return $fila[0];
	}
	
	function BuscaNCOtros($num)
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select NotCreNum from notfacotros where FacOtrosCod='".$num."'";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$fila = mysql_fetch_array($res);
		$con->cerrarBD();
		return $fila[0];
	}
	
	function BuscaNCPsmb($num)
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select NotCreNum from notfacpsmb where FacCod='".$num."'";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$fila = mysql_fetch_array($res);
		$con->cerrarBD();
		return $fila[0];
	}
	
	function BuscaNCExenta($num)
	{
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select NotCreNum from notfacpsmb where FacCod='".$num."'";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$fila = mysql_fetch_array($res);
		$con->cerrarBD();
		return $fila[0];
	}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin t&iacute;tulo</title>
<link href="../Estilos/global.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/local.css" rel="stylesheet" type="text/css" />
<link href="../Estilos/CssTabla3.css" rel="stylesheet" type="text/css" />
<script src="../include_js/jquery.js" type="text/javascript"></script>

<style>
.filaPar
{
	background:#81D371; 
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
.filaImpar
{
	background:#AEF1A1;
	font-family:Verdana, Arial, Helvetica, sans-serif; 
    font-size:11px;
	text-align:center;
	vertical-align:middle;
	padding:3px;
}
</style>
<script>
function CargaDetalle(valor)
{
	//id = document.getElementById("tablaFactura").rows[valor].cells[0].innerText;
	cliente = document.getElementById("tablaFactura").rows[valor].cells[1].innerText;
	factura = document.getElementById("tablaFactura").rows[valor].cells[2].innerText;
	//doc = document.getElementById("tablaFactura").rows[valor].cells[5].innerText;
	doc = document.getElementById("tablaFactura").rows[valor].cells[6].innerText;
	estado = document.getElementById("tablaFactura").rows[valor].cells[5].innerText;

	window.open("Contabilidad/VentanaResumenHistorico.php?fac="+factura+"&doc="+doc+"&cliente="+cliente+"&estado="+estado,"VentanaResumenHistorico","width=750,height=500,scrollbars=yes");
}

function VerNotaCredito(valor)
{
	nc = document.getElementById("tablaFactura").rows[valor].cells[0].innerText;
	//alert(nc);
	window.open("Contabilidad/VentanaNotaCredito.php?nc="+nc,"VentanaNotaCredito","width=750,height=500,scrollbars=yes");
}
</script>
</head>

<body>
<form name="form_historico_lista" id="form_historico_lista" method="post">
<?php
	extract($_POST);
	$acum = 0;
	//factura
	if ($txtFactura=="")
	{
		$txtFactura="null";
		$acum++;
	}
	else
	{$txtFactura="'".$txtFactura."'";}
	//cliente
	if ($cmb_Cliente==0) {
		$cmb_Cliente="null";
		$acum++;
	}
	else
	{$cmb_Cliente="'".$cmb_Cliente."'";}

	//fecha inicial
	if ($txtFIni=="")
	{
		$txtFIni="null";
		$acum++;
	}
	else
	{
		$FechaIni = explode("-", $txtFIni);
		$txtFIni = "$FechaIni[2]-$FechaIni[1]-$FechaIni[0]";
	}
	//fecha final
	if ($txtFFin=="")
	{
		$txtFFin="null";
		$acum++;
	}
	else
	{
		$FechaFin = explode("-", $txtFFin);
		$txtFFin = "$FechaFin[2]-$FechaFin[1]-$FechaFin[0]";
	}
	
	if($acum != 4)
	{
		//factura dia
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql = "select
		        FacDiaCod,
				CliRSocial,
				FacDiaNumFac,
				FacDiaMonto,
				date_format(FacDiaFecha,'%d/%m/%Y') as fecha,
				FacDiaEstado
				from facturadia
				inner join clientes on
				clientes.CliRut=facturadia.CliRut
				
				where 
				(($txtFactura is NULL) or (FacDiaNumFac = $txtFactura)) and
				(($cmb_Cliente is NULL) or (facturadia.CliRut = $cmb_Cliente)) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(FacDiaFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";
		$res= mysql_query($sql) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila = mysql_num_rows($res);
		//factura infa
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql2 = "select
		        FacInfaCod,
				CliRSocial,
				FacInfaNumFac,
				FacInfaMonto,
				date_format(FacInfaFecha,'%d/%m/%Y') as fecha,
				FacInfaEstado
				from facturainfa
				inner join clientes on
				clientes.CliRut=facturainfa.CliRut
				
				where 
				(($txtFactura is NULL) or (FacInfaNumFac = $txtFactura)) and
				(($cmb_Cliente is NULL) or (facturainfa.CliRut = $cmb_Cliente)) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(FacInfaFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res2= mysql_query($sql2) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila2 = mysql_num_rows($res2);
		//factura otros
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql3 = "select
		        FacOtrosCod,
				OCliRSocial,
				FacOtrosNumFac,
				FacOtrosMonto,
				date_format(FacOtrosFecha,'%d/%m/%Y') as fecha,
				FacOtrosEstado
				from facturaotros
				
				inner join otrosclientes on
				otrosclientes.OCliRut=facturaotros.OCliRut
				
				where 
				(($txtFactura is NULL) or (FacOtrosNumFac = $txtFactura)) and
				(($cmb_Cliente is NULL) or (facturaotros.OCliRut = $cmb_Cliente)) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(FacOtrosFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res3= mysql_query($sql3) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila3 = mysql_num_rows($res3);
		//factura psmb
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql4 = "select
		        FacCod,
				CliRSocial,
				FacCod,
				FacTotal,
				date_format(FacFecha,'%d/%m/%Y') as fecha,
				FacEstado
				from factura
				inner join clientes on
				clientes.CliRut=factura.CliRut
				
				where 
				(($txtFactura is NULL) or (FacCod = $txtFactura)) and
				(($cmb_Cliente is NULL) or (factura.CliRut = $cmb_Cliente)) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(FacFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";		
		$res4= mysql_query($sql4) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila4 = mysql_num_rows($res4);
		//factura exenta
		$con = new Conexion();
		$con2 = $con->conexionBD("fpproduccion");
		$sql5 = "select
				FECliNum,
				OCliRSocial,
				FECliTotal,
				date_format(FECliFecha,'%d/%m/%Y') as fecha,
				FECliEstado
				
				from facexecliente fe
				inner join otrosclientes oc on
				oc.OCliRut=fe.OCliRut
				
				where 
				(($txtFactura is NULL) or (FECliNum = $txtFactura)) and
				(($cmb_Cliente is NULL) or (fe.OCliRut = $cmb_Cliente)) and
				((($txtFIni is NULL) and ($txtFFin is NULL)) or DATE(FECliFecha) BETWEEN '".$txtFIni."' and '".$txtFFin."')";			
		$res5= mysql_query($sql5) or die ($con->error_mysql("Error en la consulta".mysql_error()));
		$con->cerrarBD();
		$fila5 = mysql_num_rows($res5);
		//echo "dia: ".$fila." infa: ".$fila2." otros: ".$fila3." psmb: ".$fila4;
		if(($fila >0)or($fila2 >0)or($fila3 >0)or($fila4 >0)or($fila5 >0))
		{?>
			<table width="100%" border="0" class="uno" cellpadding="0" cellspacing="0" id="tablaFactura">
			<thead>
  			<tr>
				<th width="8%">N. C.</th>
    			<th width="30%">Cliente</th>
    			<th width="12%">Factura</th>
    			<th width="14%">Monto ($)</th>
    			<th width="12%" title="Fecha que se efectuo la factura.">Fecha</th>
    			<th width="12%">estado</th>
				<th width="10%">doc</th>
  		    	<th width="2%">&nbsp;</th>
  			</tr>
 			</thead>
			<?php
			$aux=1;
			$cont=1;
			$total = 0;
			//factura dia
			while($reg = mysql_fetch_array($res))
			{
				if($reg['FacDiaEstado']=='NO PAGADO')
				{
					$estado = "<label style='color=red;font-weight:bold;'>NO PAGADO</label>";
					$total += $reg['FacDiaMonto'];
				}
				else
				{	
					if($reg['FacDiaEstado']=='ANULADA')
					{	$estado = "<label style='color=yellow;font-weight:bold;'>ANULADA</label>";}
					else
					{	$estado = "<label style='color=blue;font-weight:bold;'>PAGADO</label>";}
				}
				$nc = BuscaNCDia($reg['FacDiaCod']);
				if($nc!='')
				{	$valor = $nc;}
				else
				{	$valor = '';}
				
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacDiaNumFac']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacDiaMonto'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>DIA</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacDiaNumFac']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacDiaMonto'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>DIA</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
				
			}
			//factura infa
			while($reg = mysql_fetch_array($res2))
			{
				if($reg['FacInfaEstado']=='NO PAGADO')
				{
					$estado = "<label style='color=red;font-weight:bold;'>NO PAGADO</label>";
					$total += $reg['FacInfaMonto'];
				}
				else
				{	
					if($reg['FacInfaEstado']=='ANULADA')
					{	$estado = "<label style='color=yellow;font-weight:bold;'>ANULADA</label>";}
					else
					{	$estado = "<label style='color=blue;font-weight:bold;'>PAGADO</label>";}
				}
				
				$nc = BuscaNCInfa($reg['FacInfaCod']);
				if($nc!='')
				{	$valor = $nc;}
				else
				{	$valor = '';}
				
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacInfaNumFac']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacInfaMonto'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>INFA</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacInfaNumFac']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacInfaMonto'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>INFA</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
				
			}
			//factura otros
			while($reg = mysql_fetch_array($res3))
			{
				if($reg['FacOtrosEstado']=='NO PAGADO')
				{
					$estado = "<label style='color=red;font-weight:bold;'>NO PAGADO</label>";
					$total += $reg['FacOtrosMonto'];
				}
				else
				{	
					if($reg['FacOtrosEstado']=='ANULADA')
					{	$estado = "<label style='color=yellow;font-weight:bold;'>ANULADA</label>";}
					else
					{	$estado = "<label style='color=blue;font-weight:bold;'>PAGADO</label>";}
				}
				
				$nc = BuscaNCOtros($reg['FacOtrosCod']);
				if($nc!='')
				{	$valor = $nc;}
				else
				{	$valor = '';}
				
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['OCliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacOtrosNumFac']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacOtrosMonto'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>OTROS</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['OCliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacOtrosNumFac']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacOtrosMonto'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>OTROS</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
				
			}
			//factura psmb
			while($reg = mysql_fetch_array($res4))
			{
				if($reg['FacEstado']=='NO PAGADO')
				{
					$estado = "<label style='color=red;font-weight:bold;'>NO PAGADO</label>";
					$total += $reg['FacTotal'];
				}
				else
				{	
					if($reg['FacEstado']=='ANULADA')
					{	$estado = "<label style='color=yellow;font-weight:bold;'>ANULADA</label>";}
					else
					{	$estado = "<label style='color=blue;font-weight:bold;'>PAGADO</label>";}
				}
				
				$nc = BuscaNCPsmb($reg['FacCod']);
				if($nc!='')
				{	$valor = $nc;}
				else
				{	$valor = '';}
				
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacCod']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacTotal'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>PSMB</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'><a href=javascript:VerNotaCredito($aux);>".$valor."</a></td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['CliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FacCod']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FacTotal'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>PSMB</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
				
			}
			//factuta EXENTA
			while($reg = mysql_fetch_array($res5))
			{
				if($reg['FECliEstado']=='FACTURADO')
				{	
					$estado = "<label style='color=red;font-weight:bold;'>NO PAGADO</label>";
					$total += $reg['FECliTotal'];
				}
				else
				{	
					if($reg['FECliEstado']=='ANULADA')
					{	$estado = "<label style='color=yellow;font-weight:bold;'>ANULADA</label>";}
					else
					{	$estado = "<label style='color=blue;font-weight:bold;'>PAGADO</label>";}
				}
				
				if(($cont % 2)==0)
				{
					echo "<tr class=\"filaPar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'>&nbsp;</td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['OCliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FECliNum']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FECliTotal'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>EXENTA</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				else
				{
					echo "<tr class=\"filaImpar\">";
					echo "<td width=\"8%\" id=\"".$aux."\" style='text-align:center;'>&nbsp;</td>";
					echo "<td width=\"30%\" id=\"".$aux."\">".$reg['OCliRSocial']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['FECliNum']."</td>";
					echo "<td width=\"14%\" id=\"".$aux."\" style='text-align:right;padding-right:15px;'>$".number_format ($reg['FECliTotal'],0,',','.')."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$reg['fecha']."</td>";
					echo "<td width=\"12%\" id=\"".$aux."\" style='text-align:center;'>".$estado."</td>";
					echo "<td width=\"10%\" id=\"".$aux."\" style='text-align:center;'>EXENTA</td>";
					echo "<td width=\"2%\" id=\"".$aux."\"><img src='imagen/icono_documento.gif' width='14' height='18' alt='Ver Detalle' style='cursor: pointer;' onclick='CargaDetalle($aux);'/></td>";
					echo "</tr>";
				}
				$aux++;
				$cont++;
				
			}
			echo "<tr style='background-color:#CCCCCC;'>";
			echo "<td colspan='3' style='text-align:right;padding-right:15px;font-size:12px; font:Verdana; font-weight:bold; color:#000000;'>Total Pendiente:</td>";
			echo "<td style='text-align:right;padding-right:10px;font-size:12px; font:Verdana; font-weight:bold; color:#000000;'>$".number_format ($total,0,',','.')."</td>";
			echo "<td colspan='4'>&nbsp;</td>";
			echo "</tr>";
			?>
			</table>
		<?php }
		else//else $fila,$fila2,$fila3, si es igual a 0
		{
			echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">La b&uacute;squeda no gener&oacute; resultados.</label>";
		}
	}
	else//else para cuando se halla presionado el boton sin escoger una opcion de busqueda
	{
		echo "<label style=\"font:Verdana, Arial, Helvetica, sans-serif; color:#0066CC; font-weight:bold;\">La b&uacute;squeda no gener&oacute; resultados.</label>";
	}
?>
</form>
</body>
</html>
